package org.example.m7_24;

import java.util.Arrays;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[3 * n];
        for(int i = 0; i < n;i++){
            int j = i * 3;
            arr[j] = in.nextInt();
            arr[j + 1] = in.nextInt();
            arr[j + 2] = in.nextInt();
        }
        Arrays.sort(arr);
        int score = 0;
        int t = 3 * n - 2;
        for(int i = 0;i < n;i++){
            score += arr[t];
            t -= 2;
        }
        System.out.println(score);
    }
}
